#!/usr/bin/env python
# -*- coding: UTF-8 -*-
" These are the Admin configuration part for Entries"

from django.contrib import admin
from models import Entry, PingUrl, Tag, TrackbackStatus
from django.conf import settings

class PingUrlAdmin(admin.ModelAdmin):
    "Ping model Admin"
    list_display = ('ping_url', 'blog_url', 'blog_name')


class EntryAdmin(admin.ModelAdmin):
    "Entry model Admin"
    prepopulated_fields = {'slug': ('headline',) }
    list_display = ('slug', 'headline', 'pub_date', 'image')
    search_fields = ('headline','body')
    list_filter = ('pub_date', )
    
    save_on_top = True
 
    fieldsets = (
            ('Obligatoris', {
                'fields': ('headline',
                		'slug',
                        'pub_date',
                        'image', 'copyright',
                        'body_markdown',
                        'tags',
                        'related_entries',
                        'user',
                        'active',
                       ),
             }),
            ('Opcionals', {
                'classes': 'collapse',
                'fields': ('summary', 'externalId'
                           ),
            }),
            )
    class Media:
        "Javascript configuration for Entry model in Admin"
        js = [(settings.BLOG_MEDIA_PREFIX + 'js/jquery-1.2.6.pack.js'),
            (settings.BLOG_MEDIA_PREFIX + 'js/entry_change_form.js'),
            (settings.BLOG_MEDIA_PREFIX + 'js/markitup/jquery.markitup.pack.js'),
            (settings.BLOG_MEDIA_PREFIX + 'js/markitup/sets/markdown/set.js'),
            (settings.BLOG_MEDIA_PREFIX + 'js/editor.js')
            ]
        css = { 'screen': ((settings.BLOG_MEDIA_PREFIX+"js/markitup/skins/markitup/style.css"),
                          (settings.BLOG_MEDIA_PREFIX+"js/markitup/sets/markdown/style.css") )
              }

class TrackbackStatusAdmin(admin.ModelAdmin):
    "Trackback model admin"
    list_display = 'entry link status attempted message'.split()
    list_filter = ('status', )

class TagAdmin(admin.ModelAdmin):
    "Tag admin"
    pass

# ----------------------------------------------------------------------------------
# Model registration
# ----------------------------------------------------------------------------------
admin.site.register(Entry, EntryAdmin)
admin.site.register(PingUrl, PingUrlAdmin)
admin.site.register(Tag, TagAdmin)
admin.site.register(TrackbackStatus, TrackbackStatusAdmin)

#pylint says: ||admin.py|| Your code has been rated at 10.00/10 (previous run: 9.05/10)
